package com.tanglongan.designPattern.dp14_command.demo99;

public class GenericClient {

    static class Receiver {
        public void action() {
            System.out.println("执行具体操作");
        }
    }

    /**
     * 抽象命令接口
     */
    interface ICommand {
        void execute();
    }

    /**
     * 具体命令
     */
    static class ConcreteCommand implements ICommand {
        private final Receiver receiver = new Receiver();

        @Override
        public void execute() {
            this.receiver.action();
        }
    }

    /**
     * 请求者
     */
    static class Invoker {
        private final ICommand command;

        public Invoker(ICommand command) {
            this.command = command;
        }

        public void action() {
            this.command.execute();
        }
    }

    public static void main(String[] args) {
        ICommand command = new ConcreteCommand();
        Invoker invoker = new Invoker(command);
        invoker.action();
    }
}
